package com.hazardSoft.eStore.ejb;

import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import com.hazardSoft.eStore.bussines.OfferBO;
import com.hazardSoft.eStore.common.exception.SystemException;
import com.hazardSoft.eStore.entities.Offer;
import com.hazardSoft.eStore.interfaces.OfferLocal;

/**
 * Session Bean implementation class OfferEJB
 */
@Stateless
public class OfferEJB implements OfferLocal {

	public static final String EJB_NAME = OfferEJB.class.getSimpleName()+"Local";

	@PersistenceContext(unitName = "EStoreJPA")
	private EntityManager entityManager;
	private OfferBO offerBO;

	/**
	 * Default constructor. 
	 */
	public OfferEJB() {
		offerBO = new OfferBO();
	}

	/**
	 * @throws SystemException 
	 * @see OfferLocal#listOffers()
	 */
	public List<Offer> listOffers() throws SystemException {
		return offerBO.listOffers(entityManager);
	}

	/**
	 * @see OfferLocal#updateOffer(Offer)
	 */
	public Offer updateOffer(Offer offer) throws SystemException {
		return offerBO.updateOffer(offer, entityManager);
	}

	/**
	 * @see OfferLocal#insertOffer(Offer)
	 */
	public Offer insertOffer(Offer offer) throws SystemException {
		return offerBO.insertOffer(offer, entityManager);
	}

	/**
	 * @see OfferLocal#searchOfferByName(Offer)
	 */
	public Offer searchOfferByName(Offer offer) throws SystemException {
		return offerBO.searchOfferByName(offer, entityManager);
	}

	/**
	 * @see OfferLocal#searchOfferById(Offer)
	 */
	public Offer searchOfferById(Offer offer) throws SystemException {
		return offerBO.searchOfferById(offer, entityManager);
	}

	/**
	 * @see OfferLocal#removeOffer(Offer)
	 */
	public boolean removeOffer(Offer offer) throws SystemException {
		return offerBO.removeOffer(offer, entityManager);
	}

}
